package com.richapp.launcher.ui.fragments.home.demand;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.richapp.launcher.R;
import com.richapp.launcher.ui.view.TabPageView;
import com.richapp.launcher.utils.Tools;

public class SmartDemandFragment extends Fragment {
	private static final String TAG = SmartDemandFragment.class.getName();
	private ImageView demand_video, live_tv, local_play;
	private TabPageView mTabPageView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.smart_demand, container, false);
		init(view);
		return view;
	}
	
	@Override
	public void onStart() {
		super.onStart();
		
		demand_video.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Tools.openApp(getActivity(),"net.myvst.v2");
			}
		});
		
		live_tv.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Tools.openApp(getActivity(),"com.elinkway.tvlive2");
			}
		});
		
		local_play.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Tools.openApp(getActivity(),"com.softwinner.TvdFileManager");
			}
		});
		
		mTabPageView.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mTabPageView.getCurrTabView().requestFocus();
			}
		});
		
	}

	private void init(View view) {
		demand_video = (ImageView) view.findViewById(R.id.demand_video);
		live_tv = (ImageView) view.findViewById(R.id.live_tv);
		local_play = (ImageView) view.findViewById(R.id.local_play);
	}

	@Override
	public void onAttach(Activity activity) {
		mTabPageView = (TabPageView) activity.findViewById(R.id.tabPageView);
		super.onAttach(activity);
	}

	public static SmartDemandFragment getInstance() {
		return new SmartDemandFragment();
	}
}
